package com.xqledu.admin.entry.enumeration;

import lombok.AllArgsConstructor;
import lombok.Getter;
import lombok.ToString;

import java.util.Arrays;

@AllArgsConstructor
@Getter
@ToString
public enum UserEnum {
    PHONE("1","本地系统-手机号"),
    EMAIL("2","邮箱-三方"),
    ID_CARD_NUMBER("3","本地系统-身份证号"),
    WECHAT("4","微信号");
    private final String code;
    private final String message;

    // 根据 code 获取对应的枚举值
    public static UserEnum fromCode(String code) {
        return Arrays.stream(UserEnum.values())
                .filter(e -> e.getCode().equals(code))
                .findFirst()
                .orElse(null);
    }
    // 判断账号类型是否有效
    public boolean isAccountTypeValid(String accountType) {
        UserEnum userEnum = UserEnum.fromCode(accountType);
        return (userEnum == UserEnum.WECHAT || userEnum == UserEnum.PHONE);
    }

    // 判断是否为微信账号
    public boolean isWeChatAccount(String accountType) {
        UserEnum userEnum = UserEnum.fromCode(accountType);
        return userEnum == UserEnum.WECHAT;
    }

    // 判断是否为手机账号
    public boolean isPhoneAccount(String accountType) {
        UserEnum userEnum = UserEnum.fromCode(accountType);
        return userEnum == UserEnum.PHONE;
    }
    // 判断是否为邮箱账号
    public boolean isEmailAccount(String accountType) {
        UserEnum userEnum = UserEnum.fromCode(accountType);
        return userEnum == UserEnum.EMAIL;
    }
    // 判断是否为身份账号
    public boolean isIDCardNumberAccount(String accountType) {
        UserEnum userEnum = UserEnum.fromCode(accountType);
        return userEnum == UserEnum.ID_CARD_NUMBER;
    }
}
